#!/bin/sh
# Start Altera security daemons and setup log file.
#

default_directory=/usr/maxplus2
default_filename=license.dat

echo ""
echo ""
echo " MAX+plus II License Daemon Startup "
echo " Copyright (c) 1993 Altera Corporation"


dir=$1
filename=$2


if test "$dir" = "" ; then
	echo ""
	echo " Directory not specified, using $default_directory"
	dir=$default_directory
fi

if test "$filename" = "" ; then
	echo ""
	echo " Filename not specified, using $default_filename"
	filename=$default_filename
fi	

if test ! -d "$dir/adm" ; then
	echo ""
	echo " ERROR: Directory does not exist: $dir/adm "
	echo ""
	echo " Altera License Daemons NOT Started ... "
	echo ""
	exit 1
fi

if [ -r $dir/adm/lmgrd ]; then
	rm -f /usr/tmp/lockalterad

	if [ -r /usr/tmp/$filename.log ]; then
		rm -f /usr/tmp/$filename.log
	fi

	echo ""
	echo " Starting Altera License Daemons ..."
	echo ""

	$dir/adm/lmgrd -c $dir/adm/$filename \
	1>/usr/tmp/$filename.log 2>/usr/tmp/$filename.log &
else
	echo ""
	echo " ERROR: Cannot locate the license manager daemon (lmgrd)."
	echo ""
	echo " Please verify that the $dir/adm/lmgrd is accessible."
	echo ""
	echo ""
	echo " Altera License Daemons NOT Started ... "
	echo ""
fi




